﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WikiTrailCreator.TrailData;

namespace WikiTrailCreator.WikiGeneration
{
    public partial class ucWikiPhotoPanel : UserControl
    {
        private PhotoWikiPage photoWikiPage = null;

        public ucWikiPhotoPanel()
        {
            InitializeComponent();
        }

        public PhotoWikiPage PhotoWikiPage
        {
            set
            {
                ucTBWikiText.TextBoxContents = value.PageWikiCode;

                pictureBox1.ImageLocation = value.LocalImagePath;
                pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                pictureBox1.Load();

                this.URLForViewing = value.URLForViewing;
                this.URLForEditing = value.URLForEditing;
                this.URLForUploading = value.URLForUploading;
            }
        }

        private void ucTBWikiText_TextChanged(object sender, EventArgs e)
        {
            if (photoWikiPage != null)
            {
                photoWikiPage.PageWikiCode = ucTBWikiText.TextBoxContents;
            }
        }

        private void linkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start(e.Link.LinkData.ToString());
        }

        public string URLForViewing
        {
            set { linkLabelView.Links[0].LinkData = value; }
        }

        public string URLForEditing
        {
            set { linkLabelEdit.Links[0].LinkData = value; }
        }

        public string URLForUploading
        {
            set { linkLabelUpload.Links[0].LinkData = value; }
        }

    }
}
